<?php
/**
Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

// Loading all the components
$early_parent_id =$_GET['early_parent_id'];
$new_parent_id =$_GET['new_parent_id'];

$page_xml = $_GET['page_xml'];

include_once("util/backup.php");

if(!isset($semf_root) )
{
	$semf_root = '../';
	// Define that we are returning XML content & not to cache:
	header('Content-Type: text/xml');
	header('Cache-control: no-cache');
}



// build the xml
$doc = new DOMDocument();

if(file_exists($page_xml)) {
	$doc->load($page_xml);
	$doc->validate();
	$early_parent_xml = $doc->getElementById($early_parent_id);
	$new_parent_xml = $doc->getElementById($new_parent_id);
	
	
	foreach($early_parent_xml->childNodes as $child) /* it would have only one though */
	{
		$early_parent_xml->removeChild($child);
		$new_parent_xml->appendChild($child);
	}
}

savePageXML($doc, $page_xml);

//just a null message..
echo "<message></message>";


?>